home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / GRAPHICS.SWG / 0028_Another Star field.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-27  |  2KB  |  65 lines

  1. { BRendEN BEAMAN }
  2.  
  3. Program starfield;
  4. Uses
  5.   Crt, Graph;
  6.  
  7. Var
  8.   l, l2,
  9.   gd, gm,
  10.   x, y   : Integer;
  11.   rad    : Array [1..20] of Integer;
  12.   p      : Array [1..20, 1..5] of Integer;
  13.  
  14. Procedure put(p, rad : Integer; col : Word);
  15. begin
  16.   setcolor(col);  {1 pixel arc instead of putpixel}
  17.   arc(x, y, p, p + 1, rad);
  18. end;
  19.  
  20. Procedure putstar;
  21. begin
  22.   For l := 1 to 20 do      {putting stars. #15 below is color of stars}
  23.     For l2 := 1 to 5 do put(p[l, l2], rad[l], 15);
  24. end;
  25.  
  26. Procedure delstar;
  27. begin
  28.   For l := 1 to 20 do  {erasing stars}
  29.     For l2 := 1 to 5 do put(p[l, l2], rad[l], 0);
  30. end;
  31.  
  32. begin
  33.   randomize;
  34.   gd := detect;
  35.   initGraph(gd, gm, 'd:\bp\bgi');
  36.   x := 320;
  37.   y := 240;
  38.  
  39.   For l := 1 to 20 do
  40.     rad[l] := l * 10;
  41.   For l := 1 to 20 do
  42.     For l2 := 1 to 5 do
  43.       p[l, l2] := random(360);
  44.  
  45.   While not KeyPressed do
  46.   begin
  47.     delstar;
  48.     For l := 1 to 20 do
  49.     begin                {moving stars towards 'camera'}
  50.       rad[l] := rad[l] + round(rad[l] / 20 + 1); { (20)=starspeed.  }
  51.       if rad[l] > 400 then
  52.         rad[l] := l * 10;                 { starspeed must be equal }
  53.     end;                                   { to or less than 20     }
  54.     putstar;
  55.   end;
  56.   readln;
  57. end.
  58.  
  59.    The concept is fairly simple, but most people underestimate arcs...
  60.  you can set where on the circle, (0-360 degres) the arc starts, and
  61.  stops... if you set a one pixel arc at 100, and increase the radius of
  62.  the circle in a loop, it will apear to come towards you in three
  63.  dimentions... any other questions, or problems running it, contact
  64.  me... ttyl
  65.